<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/StakeholderTemplate.xhtml">

    <ui:define name="contentInsert">

        <h3>Loyalty Points Manager</h3>
        You currently have <h:outputText value ="#{StakeholderPointsMB.retrieveStakeholderLoyaltyPoints()}"/> loyalty points.

        <br/>
        <br/>
        <br/>    

        <h5>Give Loyalty Points</h5><br/>
        <h:form>  
            <p:growl id="growl2" showDetail="true" life="2000"></p:growl> 
            <h:outputLabel for="CustomerEmail" value="Customer Email: "/>
            <p:inputText id="CustomerEmail" value="#{StakeholderPointsMB.customerEmail}" required="true"
                         requiredMessage="Customer Email required!"/>
            <br/><br/>
            <h:outputLabel for="Points" value="Points to Award: "/>
            
            <p:inputText id="Points" value="#{StakeholderPointsMB.points}" required="true"
                         requiredMessage="Points to Award required!"/>
            <br/>
            <p:slider for="Points" minValue ="0" maxValue="#{StakeholderPointsMB.retrieveStakeholderLoyaltyPoints()}" style="width:200px"/>
            <br/>
             <p:commandButton id="awardPoints" value="Award Points" ajax="false"
                             actionListener="#{StakeholderPointsMB.stakeholderAwardPoints}"
                             update="display" />


        </h:form>  

        <br/>
        <br/>
        <br/>

        <h5>Buy Loyalty Points</h5>
        <h:panelGroup id="selectedChoice">
            <h:form>                                                 
                <p:dataTable var="selectedRow" value="#{StakeholderPointsMB.purchaseList}"
                             rowSelectListener="#{StakeholderPointsMB.updatePurchasePrice()}"
                             selection="#{StakeholderPointsMB.selectedPurchaseItem}" selectionMode="single" 
                             onRowSelectUpdate="selectedChoice"
                             >
                    <p:column headerText="Points"> #{selectedRow.quantity}</p:column>          
                    <p:column headerText="Price"> #{selectedRow.price}</p:column>  
                </p:dataTable>                      
            </h:form>    

            <br/>
            <br/>

            <form id="id_PaypalForm" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" 
                  style="margin-left:auto;margin-right:auto;">  

                <input type="hidden" name="cmd" value="_xclick"/>  
                <input type="hidden" name="business" value="#{returnURLMB.tCubePayPalEmail}"/>  
                <input type="hidden" name="item_name"   value="Loyalty Points Purchase"/>  
                <input type="hidden" name="item_number" value="0"/>  
                <input type="hidden" name="amount" value="#{StakeholderPointsMB.selectedPurchaseItem.price}"/>  
                <input type="hidden" name="tax" value="0"/>  
                <input type="hidden" name="quantity" value="1"/>  
                <input type="hidden" name="no_note" value="1"/>  
                <input type="hidden" name="currency_code" value="SGD"/> 
                <input type="hidden" name="return" value="#{returnURLMB.getReturnURL_stakeholderBuyPoints()}"/> 

                <input type="image" name="submit" border="0"
                       src="https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"  
                       alt="PayPal - The safer, easier way to pay online"
                       />  
            </form>  
        </h:panelGroup>






    </ui:define>

</ui:composition>
